﻿<?xml version="1.0" encoding="utf-8"?>
<!-- 
  
  If you change this file you will need to regenerate the class definition.  
  Run the following from a command prompt:
  
  sd edit LabRunDefinitionXml.cs
  "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\xsd.exe" /classes /n:Microsoft.DistributedAutomation.LabRuns.Persistence.LabRunDefinitionXml  /o:[source root]\Src\LabRunBase\Persistence  "[source root]\Src\LabRunBase\Persistence\LabRunDefinitionXml.xsd"

-->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:complexType name="MappingParameter">
    <xs:attribute name="ParameterName" type="xs:string" use="required" />
    <xs:attribute name="ParameterValue" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="LabRunParameterMappings">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="LabRunParameter" type="MappingParameter"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Reference">
    <xs:sequence>
      <xs:element name="LabRunParameterMappings" type="LabRunParameterMappings"/>
    </xs:sequence>
    <xs:attribute name="LabRunDefinitionGuid" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="Children">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="Reference" type="Reference"/>
      <xs:element maxOccurs="unbounded" name="Definition" type="Definition"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="DataStore">
    <xs:attribute name="Name" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="Properties">
    <xs:sequence>
      <xs:element minOccurs="1" maxOccurs="1" name="DataStore" type="DataStore"/>
    </xs:sequence>
  </xs:complexType>

  <xs:simpleType name="Operator" >
    <xs:restriction base='xs:string' >
      <xs:enumeration value='None' />
      <xs:enumeration value='BeginsWith' />
      <xs:enumeration value='Contains' />
      <xs:enumeration value='Equals' />
      <xs:enumeration value='EqualsGreater' />
      <xs:enumeration value='EqualsLess' />
      <xs:enumeration value='Greater' />
      <xs:enumeration value='Has' />
      <xs:enumeration value='HasNot' />
      <xs:enumeration value='IsNotNull' />
      <xs:enumeration value='IsNull' />
      <xs:enumeration value='Less' />
      <xs:enumeration value='NotBeginsWith' />
      <xs:enumeration value='NotContains' />
      <xs:enumeration value='NotEquals' />
      <xs:enumeration value='NotWithin' />
      <xs:enumeration value='Within' />
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="JobSelection">
    <xs:sequence>
      <xs:any minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ScheduleParameter">
    <xs:attribute name="Feature" type="xs:string" />
    <xs:attribute name="JobName" type="xs:string" />
    <xs:attribute name="Name" type="xs:string" use="required" />
    <xs:attribute name="ParameterVal" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="ParameterCollection">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="Parameter" type="ScheduleParameter"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ScheduleParameters">
    <xs:sequence>
      <xs:element name="ParameterCollection" type="ParameterCollection"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ConstraintValue">
    <xs:attribute name="ConstraintVal" type="xs:string" use="required" />
  </xs:complexType>


  <xs:complexType name="Constraint">
    <xs:sequence minOccurs="1" maxOccurs="unbounded">
      <xs:element name="ConstraintValue" type="ConstraintValue"/>
    </xs:sequence>
    <xs:attribute name="DimensionName" type="xs:string" use="required" />
    <xs:attribute name="QueryOperatorId" type="Operator" use="required" />
  </xs:complexType>

  <xs:complexType name="ConstraintCollection">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="Constraint" type="Constraint"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Constraints">
    <xs:sequence>
      <xs:element name="ConstraintCollection" type="ConstraintCollection"/>
    </xs:sequence>
  </xs:complexType>

  <xs:simpleType name='CombinatoryType' >
    <xs:restriction base='xs:string' >
      <xs:enumeration value='Flat' />
      <xs:enumeration value='FullCombination' />
      <xs:enumeration value='NTupleWise' />
      <xs:enumeration value='Random' />
      <xs:enumeration value='Any' />
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="ConfigurationsSetting">
    <xs:attribute name="Seed" type="xs:unsignedLong" use="required" />
    <xs:attribute name="CombinatoryType" type="CombinatoryType" use="required" />
    <xs:attribute name="CombinatoryOrder" type="xs:unsignedLong" use="required" />
  </xs:complexType>

  <xs:complexType name="ParameterValue">
    <xs:attribute name="Value" type="xs:string" use="required"  />
  </xs:complexType>

  <xs:complexType name="ParameterValues">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="ParameterValue" type="ParameterValue"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Parameter">
    <xs:sequence>
      <xs:element name="ParameterValues" type="ParameterValues"/>
    </xs:sequence>
    <xs:attribute name="Name" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="Parameters">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="Parameter" type="Parameter"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="DimensionValue">
    <xs:attribute name="Value" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="DimensionValues">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="DimensionValue" type="DimensionValue"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name ="Dimension">
    <xs:sequence>
      <xs:element name="DimensionValues" type="DimensionValues"/>
    </xs:sequence>
    <xs:attribute name="Name" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="Dimensions">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="Dimension" type="Dimension"/>
    </xs:sequence>
  </xs:complexType>

  <xs:simpleType name="ConditionOperator" >
    <xs:restriction base='xs:string' >
      <xs:enumeration value='Equals' />
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="Condition">
    <xs:attribute name="ParameterName" type="xs:string" use="required" />
    <xs:attribute name="ParameterValue" type="xs:string" use="required" />
    <xs:attribute name="ConditionOperator" type="ConditionOperator" use="required" />
  </xs:complexType>

  <xs:complexType name="Statement">
    <xs:sequence>
      <xs:element name="ParameterValues" type="ParameterValues"/>
    </xs:sequence>
    <xs:attribute name="ParameterName" type="xs:string" use="required" />
  </xs:complexType>

  <xs:simpleType name="Criteria" >
    <xs:restriction base='xs:string' >
      <xs:enumeration value='Inclusion' />
      <xs:enumeration value='Exclusion' />
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="ParameterRule">
    <xs:sequence>
      <xs:element name="Condition" type="Condition"/>
      <xs:element name="Statement" type="Statement"/>
    </xs:sequence>
    <xs:attribute name="Criteria" type="Criteria" use="required" />
  </xs:complexType>

  <xs:complexType name="ParameterRules">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="ParameterRule" type="ParameterRule"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Configurations">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="ConfigurationsSetting" type="ConfigurationsSetting"/>
      <xs:element minOccurs="0" maxOccurs="1" name="Parameters" type="Parameters"/>
      <xs:element minOccurs="0" maxOccurs="1" name="Dimensions" type="Dimensions"/>
      <xs:element minOccurs="0" maxOccurs="1" name="ParameterRules" type="ParameterRules"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Definition">
    <xs:sequence>
      <xs:element minOccurs="1" maxOccurs="1" name="Properties" type="Properties"/>
      <xs:element minOccurs="1" maxOccurs="1" name="JobSelection" type="JobSelection"/>
      <xs:element minOccurs="0" maxOccurs="1" name="ScheduleParameters" type="ScheduleParameters"/>
      <xs:element minOccurs="0" maxOccurs="1" name="Constraints" type="Constraints"/>
      <xs:element minOccurs="0" maxOccurs="1" name="Configurations" type="Configurations"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name ="LabRunParameter">
    <xs:attribute name="Name" type="xs:string" use="required" />
    <xs:attribute name="Description" type="xs:string" use="optional" default="" />
    <xs:attribute name="DefaultValue" type="xs:string" use="optional" default="" />
    <xs:attribute name="IsSystem" type="xs:boolean" use="optional" default="false" />
    <xs:attribute name="IsConstant" type="xs:boolean" use="optional" default="false"/>
  </xs:complexType>

  <xs:complexType name ="ResultSummaryProperty">
    <xs:attribute name="PropertyName" type="xs:string" use="required" />
    <xs:attribute name="PropertyValue" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name ="ResultSummaryProperties">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="ResultSummaryProperty" type="ResultSummaryProperty"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name ="LabRunParameters">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="LabRunParameter" type="LabRunParameter"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="LabRunDefinition">
    <xs:sequence>
      <xs:element minOccurs="1" maxOccurs="1" name="LabRunParameters" type="LabRunParameters"/>
      <xs:choice minOccurs="1" maxOccurs="1">
        <xs:element name="Children" type="Children" />
        <xs:element name="Definition" type="Definition"/>
      </xs:choice>
      <xs:element minOccurs="1" maxOccurs="1" name="ResultSummaryProperties" type="ResultSummaryProperties"/>
    </xs:sequence>
  </xs:complexType>

  <xs:element name="LabRunDefinition" type="LabRunDefinition"/>
</xs:schema>